package com.jay.lang.management.intf;

import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;
import java.util.List;

public class MemoryPoolMXBeanIntf {
	public static void main(String[] args) throws IOException {
		List<MemoryPoolMXBean> mxbeans = ManagementFactory
				.getMemoryPoolMXBeans();
		for (MemoryPoolMXBean mbean : mxbeans) {
			System.out.println("----------------");
			System.out.println(mbean.getName());
			System.out.println(mbean.toString());
			System.out.println(mbean.getClass());
			System.out.println(mbean.getObjectName());
			System.out.println(mbean.isValid());
			System.out.println(mbean.getCollectionUsage());
			System.out.println(mbean.getPeakUsage());
			System.out.println(mbean.getType());
			System.out.println(mbean.getUsage());
			String[] names = mbean.getMemoryManagerNames();
			for (String s : names) {
				System.out.println(s);
			}
			System.out.println("Is CollectionUsage Supported?");
			if (mbean.isCollectionUsageThresholdSupported()) {
				System.out.println(mbean.getCollectionUsageThreshold());
				System.out.println(mbean.getCollectionUsageThresholdCount());
				System.out.println(mbean.isCollectionUsageThresholdExceeded());
			}
			System.out.println("Is Usage Supported?");
			if (mbean.isUsageThresholdSupported()) {
				System.out.println(mbean.getUsageThreshold());
				System.out.println(mbean.getUsageThresholdCount());
				System.out.println(mbean.isUsageThresholdExceeded());
			}
		}
	}
}
